﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace YUIAspNet.HtmlHelpers
{
    internal static class ReflectionHelper
    {
        internal static Dictionary<string, object> GetProperties(object item)
        {
            Dictionary<string, object> props = new Dictionary<string, object>();
            foreach (PropertyInfo property in item.GetType().GetProperties())
            {
                //props.Add(property.Name, () => property.GetValue(item, null));
                props.Add(property.Name, property.GetValue(item, null));
            }

            return props;
        }
    }

    internal class NameValue<TName, TValue>
    {
        public TName Name { get; private set; }
        public TValue Value { get { return valueFunction(); } }

        Func<TValue> valueFunction;

        public NameValue(TName name, Func<TValue> valueFunction)
        {
            Name = name;
            this.valueFunction = valueFunction;
        }
    }
}
